package com.eveinfo.api.utils.certificates;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

public class ApiClass implements Serializable, Comparable<ApiClass> {

	private static final long serialVersionUID = 4882168972687698147L;

	private final int ID;
	private final String name;
	private final ArrayList<ApiCertificate> certificates;

	public ApiClass(int ID, String name) {
		certificates = new ArrayList<ApiCertificate>(10);
		this.ID = ID;
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public int getID() {
		return ID;
	}

	public boolean addCertificate(ApiCertificate certificate) {
		return certificates.add(certificate);
	}

	public Collection<ApiCertificate> getCertificates() {
		return certificates;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("  " + name + "\n");
		return sb.toString();
	}

	public ApiCertificate getCertificate(int certificateID) {
		for(ApiCertificate certificate : certificates){
			if(certificate.getID() == certificateID){
				return certificate;
			}
		}
		return null;
	}

	@Override
	public int compareTo(ApiClass o) {
		return name.compareTo(o.getName());
	}
}
